package com.panda.system.utils;


import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
import com.aliyun.teaopenapi.models.Config;

public class AliSendSmsUtil {

    /**
     * 使用AK&SK初始化账号Client
     * @param accessKeyId a
     * @param accessKeySecret a
     * @return Client
     */
    private static com.aliyun.dysmsapi20170525.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        Config config = new Config()
                // 您的AccessKey ID
                .setAccessKeyId(accessKeyId)
                // 您的AccessKey Secret
                .setAccessKeySecret(accessKeySecret);
        // 访问的域名
        config.endpoint = "dysmsapi.aliyuncs.com";
        return new com.aliyun.dysmsapi20170525.Client(config);
    }

    public static void sendSms(SendSmsRequest sendSmsRequest,String accessKeyId,String accessKeySecret){
        try {
            com.aliyun.dysmsapi20170525.Client client = AliSendSmsUtil.createClient(accessKeyId, accessKeySecret);
            // 复制代码运行请自行打印 API 的返回值
            client.sendSms(sendSmsRequest);
        }catch (Exception e){
            e.printStackTrace();

        }
    }
}
